package com.lgh.demo.util;

import java.util.ArrayList;
import java.util.List;

public class DataUtils {

    public static void addNullToListData(List list, int maxLength) {
        int startIndex = 0;
        if (list != null) {
            startIndex = list.size();
        } else {
            list = new ArrayList<>();
        }
        for (int i = startIndex; i < maxLength; i++) {
            list.add(null);
        }
    }

    public static int getTotalPage(int totalNum, int pageSize) {
        int size = 0;
        if (totalNum == 0 || pageSize == 0) {
            return size;
        }
        if (totalNum % pageSize == 0) {
            return totalNum / pageSize;
        }
        if (totalNum % pageSize != 0) {
            return totalNum / pageSize + 1;
        }
        return size;
    }

}
